Using the Trajectory List Box 3D node

Use the Trajectory List Box 3D node to create scrollable lists of items arranged along a trajectory. The items in a Trajectory List Box 3D node appear in the order you add them to the Trajectory List Box 3D node. To select an item in a Grid List Box node click or tap the item.

The size of the trajectory defines the interactive area for click and drag gestures. If the trajectory is too small, users will not be able to select the items in the Trajectory List Box 3D node. To avoid this, make sure the trajectory is large enough. See Using circle trajectories, Using line trajectories, and Using spline trajectories.

Note that items in all list box nodes (Grid List Box nodes and Trajectory List Box 3D node) are not its child nodes, even though in Kanzi Studio it seems so when you add items to a list box. Because list box items are not child nodes of a list box, you cannot refer to these items from outside of a list box using paths or aliases. If you need to refer from a list box item to an object outside of a list box, use bindings and aliases. See Binding to properties outside of a Trajectory List Box 3D node and Navigating to Page nodes from a Trajectory List Box 3D node.

Trajectory List Box 3D node is an interactive version of the Trajectory Layout nodes. See Using the Trajectory Layout nodes.

Creating a Trajectory List Box 3D node

To create a Trajectory List Box 3D node:

  1. In the Project press Alt and right-click the node where you want to create a Trajectory List Box 3D node and select Trajectory List Box 3D.
    Note that you can create the Trajectory List Box 3D node only inside 3D nodes.
    To see the trajectory, in the Preview click and use the drop-down menu to enable visualization of Debug objects.
  2. In the Project add items to the Trajectory List Box 3D node.
    For example, add several Sphere nodes.
    As you add items, the Trajectory List Box 3D node arranges them along the trajectory used by the Trajectory List Box 3D node.
    To browse the items in a Trajectory List Box 3D node, in the Preview click and drag the items in the Trajectory List Box 3D node.
  3. (Optional) Kanzi Studio creates and uses a circle trajectory by default. You can use a circle, line, or a spline trajectory. See Trajectories.

Fine tuning the mechanics of a Trajectory List Box 3D node

You can fine tune the mechanics of a list box. You can set the list box to:

Binding to properties outside of a Trajectory List Box 3D node

Use an alias when you want to bind a property of a list box item to a property of a node outside of the list box.

For example, if you have a Grid List Box 3D or a Trajectory List Box 3D node with a Text Block 3D node item and want to set the Text property value of the Text Block 3D node to a value of an Empty Node 3D node property that is not in the list box:

  1. In the Project press Alt and right-click the nodes that contain the property to which you want to bind and select Alias. See Using aliases.
    For example, create an alias for the Empty Node 3D node.
  2. In the Window select Context Resources and in the Context Resources window make sure that the aliases you created are in the resource dictionary that the list box node can access.
    For example, place all aliases to the resource dictionary of the Screen node, or create a resource dictionary in the list box node and place the aliases to that resource dictionary. See Using local and global resources.
  3. Create the binding:
    1. In the Project select the node inside the list box node from which you want to bind to a node outside of the list box node.
    2. In the Properties add the Bindings property and create the binding using the alias to bind to the property in a node outside of the list box node.
      For example, in the Text Block 3D node create a binding to the Empty Node 3D node using the alias you created in the first step. See Reference for bindings expressions.
      For example, use this binding expression
      {#Empty Node 3D/TextBlock.Text}
      .
      The Text property in the Text Block 3D node gets the value of the Text property from the Empty Node 3D node.
    3. Click Save.

Navigating to Page nodes from a Trajectory List Box 3D node

Use an alias when you want to navigate to a Page node from a node that is inside a list box node. For example, if you use a Grid List Box or a Trajectory List Box 3D node to create an address book and want to show the content of an address book entry in a Page node.

To navigate to Page nodes from a list box node:

  1. In the Project press Alt and right-click each Page node to which you want to navigate to and select Alias.
    Kanzi Studio creates an alias that points to the node from which you created it, and places the alias to the nearest resource dictionary.
  2. In the Window select Context Resources and in the Context Resources window make sure that the aliases you created are in the resource dictionary that the list box node can access.
    For example, place all aliases to the resource dictionary of the Screen node, or create a resource dictionary in the list box node and place the aliases to that resource dictionary. See Using local and global resources.
  3. Add and set the Navigate to Page action:
    1. In the Project in the list box node select the node that contains the trigger you want to use to navigate to one of the Page nodes for which you created the alias in the first step.
    2. In the Triggers in the trigger you want to use to navigate to the Page node add the Navigate to Page action.
    3. In the Navigate to Page settings window set the Item property to the alias of the Page node to which you want to navigate.
    4. Click Save.

In the Preview when you click the node that contains the Navigate to Page action, you activate the Page node selected in the action.

Trajectory list box example

This example shows the use of the Trajectory List Box 3D node to create an interactive scrollable list of items. The example implements a simple gallery of photos with a selection effect using an animation.

The Trajectory List Box 3D node, its Circle Trajectory, content shown in the Trajectory List Box 3D, and animation that highlights the centered photo are created in Kanzi Studio. The point of time at which a highlight-animation is launched is defined based on the scroll speed and focused item data available from the user input events that the trajectory list box component produces.

The Trajectory List Box 3D node in the example uses these features:

You can find the example in <KanziWorkspace>/Examples/Trajectory_list_box.

Using the Trajectory List Box 3D node in the API

To create a Trajectory List Box 3D:

// Create a Trajectory List Box 3D named MyListBox.
TrajectoryListBox3DSharedPtr trajectoryListBox = TrajectoryListBox3D::create(domain, "MyListBox");

To set the trajectory you want the list box to use:

// Create a circle trajectory named Circle with radius of 4 device independent units.
TrajectorySharedPtr trajectoryResource = Trajectory::createCircle(Vector3(), Vector3::up(), 0.0f, 4.0f, domain, "Circle");
resourceManager->registerResource("MyResources:///MyTrajectory", trajectoryResource);
trajectoryListBox->addResource(ResourceID("MyTrajectory"), "MyResources:///MyTrajectory");

// Set the list box to use the trajectory.
trajectoryListBox->setTrajectoryResourceID(ResourceID("MyTrajectory"));
// Increase the layout size to cover the whole trajectory.
trajectoryListBox->setWidth(10.0f);
trajectoryListBox->setDepth(10.0f);
trajectoryListBox->setHeight(3.0f);

To add items to the list box:

// Create cube meshes and add them as items of the trajectory list box.
// Items on the trajectory appear in the order you add them to the list.
Model3DSharedPtr item1 = Model3D::createCube(domain, "item1", 1.0f, KanziThemeRed);
Model3DSharedPtr item2 = Model3D::createCube(domain, "item2", 1.0f, KanziThemeGreen);
Model3DSharedPtr item3 = Model3D::createCube(domain, "item3", 1.0f, KanziThemeBlue);
Model3DSharedPtr item4 = Model3D::createCube(domain, "item4", 1.0f, KanziThemeOrange);
Model3DSharedPtr item5 = Model3D::createCube(domain, "item5", 1.0f, KanziThemeYellow);
trajectoryListBox->addItem(item1);
trajectoryListBox->addItem(item2);
trajectoryListBox->addItem(item3);
trajectoryListBox->addItem(item4);
trajectoryListBox->addItem(item5);

To make the list box loop:

// Make the list box looping. All items fit to the trajectory so they are positioned evenly.
trajectoryListBox->setLoopAlongX(true);

To set selection behavior:

// Make clicking items bring them to the center of the trajectory.
trajectoryListBox->setSelectionBehavior(ListBoxConcept::SelectionBehaviorBringToCenter);
// Change the position where the clicked items are brought to be one quarter from the beginning of the trajectory.
trajectoryListBox->setCursorOffset(0.25f);

For details, see the API reference.

See also

Using the Grid List Box nodes

Using the Trajectory Layout nodes

Using circle trajectories

Using line trajectories

Using spline trajectories

Using bindings